from plot.die import Die
import pygal

die = Die()
results = []

for num in range(1000):
    die_num = die.roll()
    results.append(die_num)

# 分析结果
frequencies = []
for value in range(1, die.num_sides + 1):
    frequency = results.count(value)
    frequencies.append(frequency)

# 绘制直方图
line_chart = pygal.Bar()

line_chart.title = "1000次骰子的执行情况"
line_chart.x_labels = range(1, 7)
line_chart._x_title = "Result"
line_chart.y_title = "Frequency of Result"

line_chart.add("D6", frequencies)
line_chart.render_to_file("die_visual.svg")
